package ${project.basePkg}.${model.module}.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
<#--
<#if property.validateLengthMin != null || property.validateLengthMax != null >
import org.hibernate.validator.constraints.Length;
</#if>
<#if property.validateRegex??>
import javax.validation.constraints.Pattern;
</#if>
-->

<#list imports as import>
import ${import};
</#list>
import java.io.Serializable;

/**
 * ${model.name}数据传输对象
 *
 * @author ${model.author}
 * @date ${.now?date?string["yyyy/MM/dd"]}
 */
@Data
@Schema(description = "${model.name}传输对象")
public class ${model.code}DTO implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    <#list properties as property>
    <#-- 只生成在新增表单或编辑表单中使用的字段 -->
    <#if (property.formAddShow)!true || (property.formEditShow)!true>
    /**
     * ${property.fieldLabel}
     */
    <#-- 设置Long类型JSON序列化为String，解决前端大数精度丢失问题 -->
    <#if property.fieldType == 'Long' && property.fieldName != 'deleted'>
    @JsonSerialize(using = ToStringSerializer.class)
    </#if>
    <#-- OpenAPI接口文档注解 -->
    @Schema(description = "${property.fieldLabel!''}"<#if (property.fieldExample)?has_content>, example = "${property.fieldExample}"</#if><#if property.validateLengthMin gt 0>, minLength = ${property.validateLengthMin}</#if><#if property.validateLengthMax gt 0>, maxLength = ${property.validateLengthMax}</#if>)
    <#-- 长度校验注解 -->
    <#if property.validateLengthMin gt 0 && property.validateLengthMax gt 0>
    @Length(min = ${property.validateLengthMin}, max = ${property.validateLengthMax}, message = "${property.fieldLabel}的长度应在${property.validateLengthMin}到${property.validateLengthMax}个字符之间")
    <#elseif property.validateLengthMax gt 0>
    @Length(max = ${property.validateLengthMax}, message = "${property.fieldLabel}的长度不能超过${property.validateLengthMax}个字符")
    <#elseif property.validateLengthMin gt 0>
    @Length(min = ${property.validateLengthMin}, message = "${property.fieldLabel}的长度至少应为${property.validateLengthMin}个字符")
    </#if>
    <#-- 正则表达式注解 -->
    <#if (property.validateRegex)?has_content >
    @Pattern(regexp = "${property.validateRegex}", message = "${property.fieldLabel}格式错误【${property.validateRegex}】")
    </#if>
    private ${property.fieldType} ${property.fieldName};

    </#if>
    </#list>
}